import request from '@/router/axios';

export const saveOrUpdate = (data) => {
	data.type = 2;
	return request({
		url: '/activity/activity/saveOrUpdate',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: data
	})
}
export const getActList = (page, size, params) => {
	return request({
		url: '/activity/activity/list',
		method: 'post',
		params: {
			...params,
			page,
			size,
		}
	})
}
// 申请列表
export const getList = (page, size, params) => {
	return request({
		url: 'activity/activityGoods/list',
		method: 'post',
		params: {
			...params,
			page,
			size,
		}
	})
}
export const listActivity = (page, size, params) => {
	return request({
		url: '/activity/activityGoods/list',
		method: 'post',
		params: {
			...params,
			page,
			size,
			goodsStatus:0
		}
	})
}

// 审核
export const joinActivityAudit = ( data) => {
	return request({
		url: '/activity/activityGoods/joinActivityAudit',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data:data
	})
}
// 取消
export const cancel = ( id) => {
	return request({
		url: '/activity/activity/cancel',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data:{id}
	})
}

//验证活动输入的折扣
export function testAcRebate(rule, value, callback) {
	if(!value){
		return callback(new Error('输入不可以为空'));
	}else if(!Number(value)){
		return callback(new Error('输入值需要为数字值'));
	}else if(value<0 ||  value>=10){
		return callback(new Error('值要大于0小于10'));
	}else{
		callback();
	}
}


// 审核
export const loadStore = () => {
	return request({
		url: '/base/store/getStoreMap',
		method: 'post',
	})
}

// 根据店铺Id查询店铺计提比例
export const getStoreExtractRate = (data) => {
	return request({
		url: '/base/store/getStoreExtractRate',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: data,
	})
}

// 活动sku
export const activityGoodsSku = (data) => {
	return request({
		url: '/activity/activityGoodsSku/list',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data:data,
	})
}

// 设置平台奖励
export const setPlatformReward = (data) => {
	return request({
		url: '/activity/activityGoodsSku/setPlatformReward',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data:data,
	})
}

// 平台审核店铺活动
export const platformAuditAct = (actId,acStatus) => {
	return request({
		url: '/activity/activity/platformAuditAct',
		method: 'post',
		params:{
			actId,
			acStatus
		}
	})
}
// 根据商品id和活动id获得活动信息和团长信息
export const getActivityInfoAndGroupLeaderInfo = (goodsId, acId) => {
	return request({
		url: '/activity/activityCollage/getActivityInfoAndGroupLeaderInfo',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data:{
			goodsId,
			 acId
		}
	})
}

// 根据商品id和活动id获得活动信息和团长信息
export const getOrganizationByIds = (ids) => {
	return request({
		url: '/base/organization/getOrganizationByIds',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data:{
			ids
		}
	})
}

